package com.cssw.fyzb.busi.api.video;

import com.cssw.fyzb.busi.service.video.VideoService;
import com.ydn.appserver.Action;
import com.ydn.appserver.Request;
import com.ydn.appserver.Response;
import com.ydn.appserver.annotations.Function;
import com.ydn.appserver.annotations.Parameter;
import com.ydn.appserver.annotations.Type;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 举报视频
 *
 * @author YangYiQun
 */
@Function(description = "举报视频", parameters = {
        @Parameter(name = "userId", type = Type.Integer, description = "用户标识", required = true),
        @Parameter(name = "videoId", type = Type.Integer, description = "视频标识", required = true)
})
@Component
public class ReportVideo implements Action {

    @Autowired
    private VideoService videoService;

    private static final Logger logger = LoggerFactory.getLogger(ReportVideo.class);

    @Override
    public Response execute(Request request) throws Exception {
        Long userId = request.getLong("userId");
        Long videoId = request.getLong("videoId");
        try {
            videoService.report(userId, videoId);
            return Response.success();
        } catch (Exception e) {
            logger.info("", e);
            return Response.fail("操作异常");
        }
    }
}
